﻿/// <summary>
/// https://leetcode-cn.com/problems/integer-to-roman/
/// </summary>
public class Solution
{
    private enum RomanDigit : int
    {
        I = 1,
        IV = 4,
        V = 5,
        IX = 9,
        X = 10,
        XL = 40,
        L = 50,
        XC = 90,
        C = 100,
        CD = 400,
        D = 500,
        CM = 900,
        M = 1000
    }
    public string IntToRoman(int num)
    {
        var romanDigits = Enum.GetValues<RomanDigit>();

        System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
        foreach (var romanDigit in romanDigits.Reverse())
        {
            var count = num / (int)romanDigit;
            for (int i = 0; i < count; i++)
            {
                _ = stringBuilder.Append(romanDigit.ToString());
            }
            num %= (int)romanDigit;
        }
        return stringBuilder.ToString();
    }
}